//
//  XHRAboutProductViewController.m
//  快医
//
//  Created by 胥鸿儒 on 16/7/6.
//
//

#import "XHRAboutProductViewController.h"


//define this constant if you want to use Masonry without the 'mas_' prefix
#define MAS_SHORTHAND

//define this constant if you want to enable auto-boxing for default syntax
#define MAS_SHORTHAND_GLOBALS

#import "Masonry.h"
#import <SVProgressHUD.h>
@interface XHRAboutProductViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong) NSArray *dataArray;

@end


@implementation XHRAboutProductViewController
-(NSArray *)dataArray{

    if (_dataArray == nil ) {
        
        self.dataArray = @[@"用户协议"];

    }
    return _dataArray;
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.tableView.delegate = self;
    self.tableView.dataSource =self;
    
    [self setUpUI];

}

//界面布局

//组
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return 1;

}

//多少行
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return self.dataArray.count;
}

//内容

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    UITableViewCell *cell = [[UITableViewCell alloc] init];

    cell.textLabel.text = self.dataArray[indexPath.row];
    cell.imageView.image = [UIImage imageNamed: @"product_img_icon_xieyi.png"];
    cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"illness_button_input_blue.png"]];

    return cell;
}

-(void)setUpUI{
    
    CGFloat w = self.view.bounds.size.width;
    CGFloat h = self.view.bounds.size.height;

    UIView *allHeadView = [[UIView alloc] initWithFrame:CGRectMake(0,64,w,h * 0.3)];
    
    UIImageView *imageView = [[UIImageView alloc] init];
    
    imageView.image = [UIImage imageNamed:@"product_img_logo_nor.png"];
    
    [allHeadView addSubview:imageView];//******要先添加图片 在设置约束
    
    [imageView makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.offset(0);
        make.centerY.offset(-30);
        
    }];

    UIImageView *QcView = [[UIImageView alloc] init];
    
    QcView.image = [UIImage imageNamed:@"product_text_logo_nor.png"];
    
    [allHeadView addSubview:QcView];//******要先添加图片 在设置约束
    
    [QcView makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.offset(0);
        make.centerY.offset(50);

    }];
 
    self.tableView.tableHeaderView = allHeadView;

    UIView *allFoodView = [[UIView alloc] initWithFrame:CGRectMake(0,400,w, h * 0.5)];
    UILabel *qqNum= [[UILabel alloc] init ];
    
    qqNum.textColor = [UIColor blueColor];
    qqNum.text = @"用户交流群 :   4638375473";
    
    [allFoodView addSubview:qqNum];
    
    [qqNum makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.offset (0);
        
        make.centerX.offset (0);
    }];

    UILabel *versionNum = [[UILabel alloc] initWithFrame:CGRectMake(120, 220, 175, 50)];
    
    versionNum.text = @"version :   1.4.0";
    versionNum.textColor = [UIColor blueColor];
    
    [allFoodView addSubview:versionNum];
    
    [versionNum makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.offset (20);
        make.centerX.offset (-19);
 
    }];
 
    self.tableView.tableFooterView = allFoodView;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    [SVProgressHUD setMinimumDismissTimeInterval:1];
    
    [SVProgressHUD showSuccessWithStatus:@"用户协议"];
    
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];

    }

@end
